<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:param name="param_pageTitle"
		value="#{messages.luyuan_crm_menu_order}" />
	<ui:param name="param_navigationUrl"
		value="/luyuan/sale/layout/navigationSale.jsf" />

	<ui:define name="road">
		<span>待发货订单</span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<h:form>
				<rg:areaPanel type="searchPanel">
					<rg:fieldSet column="auto">
						<rg:inputText value="#{orderStorageAction.uuid}" label="订单号" />
						<rg:selectOne id="expressCompany"
							value="#{orderStorageAction.expressCompany}" label="快递方式"
							enableEmpty="true" itemsProvider="#{expressCompanyProvider}" converter="#{expressCompanyConverter}" />
						<rg:selectOne id="status" label="订单状态"
							value="#{orderStorageAction.orderStatus}"
							converter="#{orderStatusConverter}"
							itemsProvider="#{orderStorageAction}" />
						
						<rg:field label="制单时间">
							<rg:datetime value="#{orderStorageAction.startDate}" datePattern="yyyy-MM-dd HH:mm" showApplyButton="false" />
							<rg:datetime value="#{orderStorageAction.endDate}" datePattern="yyyy-MM-dd HH:mm" showApplyButton="false" />
						</rg:field>

						<h:commandButton styleClass="button"
							value="#{messages.luyuan_crm_query}" />
					</rg:fieldSet>
				</rg:areaPanel>

				<rg:titlePanel headerTitle="待发货订单"
					style="margin-top: 10px;" readonly="false">
					<ui:define name="headerActions">
						<h:commandLink
							actionListener="#{orderStorageAction.exportEMSExcel()}"
							oncomplete="" value="按EMS格式导出查询数据" />
						<h:commandLink
							actionListener="#{orderStorageAction.exportSFExcel()}"
							oncomplete="" value="按顺丰格式导出查询数据" />
					</ui:define>
					<rg:table id="orderTable"
						value="#{orderStorageAction.orderTableModel}" var="item">
						<rg:column property="id" title="订单号" sortable="false"/>
						<rg:column property="orderType" title="订单类型"
							converter="#{orderTypeConverter}"  sortable="false"/>
						<rg:column property="createTime" title="制单时间"  sortable="false" 
							datePattern="yyyy-MM-dd HH:mm" converter="#{dateConverter}" />
						<rg:column property="customer.name" title="购买会员"  sortable="false"/>
						<rg:column property="delivery.expressCompany" title="快递方式" converter="#{expressCompanyConverter}" />
						<rg:column title="当前状态" > 
							<h:outputLabel value="未打印" rendered="#{item.printCount eq 0}"/>
							<h:outputLabel value="已打印" style="color:blue" rendered="#{item.printCount ne 0}"/>
							<h:outputLabel value="未导出" rendered="#{item.exportCount eq 0}"/>
							<h:outputLabel value="已导出" style="color:blue" rendered="#{item.exportCount ne 0}"/>
						</rg:column>

						<rg:column type="oper" title="#{messages.luyuan_crm_operator}">
							<ul class="links">
								<li>
									<h:commandLink rendered="#{item.orderStatus eq 'VERIFIED'}"
										onclick="UI.instance.showDialog({id:'changeOrderStatus', src:'/luyuan/sale/updateOrderForStorage.jsf?uuid=#{item.id}'});"
										value="发货">
									</h:commandLink>
									<h:commandLink rendered="#{item.orderStatus eq 'DELIVERED'}" style="color:blue;"
										onclick="UI.instance.showDialog({id:'changeOrderStatus', src:'/luyuan/sale/updateOrderForStorage.jsf?uuid=#{item.id}'});"
										value="修改快递">
									</h:commandLink>
								</li>
								<li>
									<h:commandLink rendered="#{item.orderStatus eq 'VERIFIED'}"
										onclick="UI.instance.showDialog({id:'returnedUpdate', src:'/luyuan/sale/updateOrderForStorageUpdating.jsf?uuid=#{item.id}'});"
										value="退回修改">
									</h:commandLink></li>
								<li>
									<h:panelGroup rendered="#{orderStorageAction.isSingleProduct(item)}">
										<a href="#{ctx}/luyuan/sale/printProducts.jsf?orderId=#{item.id}"
											target="_blank" class="button larger">打印</a>
									</h:panelGroup>
								</li>
								<li>
									<h:panelGroup rendered="#{orderStorageAction.isFormula(item)}">
										<a href="#{ctx}/luyuan/sale/printFormula.jsf?orderId=#{item.id}"
											target="_blank" class="button larger">打印</a>
									</h:panelGroup>
								</li>
								<li>
									<a href="#{ctx}/luyuan/sale/orderViewForStorage.jsf?id=#{item.id}" >详细订单</a>
								</li>
							</ul>
						</rg:column>
					</rg:table>
				</rg:titlePanel>
			</h:form>
		</rg:areaPanel>
		<a:form>
			<a:jsFunction name="reRenderOrderTableModel" reRender="orderTable" />
		</a:form>
	</ui:define>
</ui:composition>